<?php
    // enums
    define('MEMBER', '1');
    define('NON_MEMBER', '0');
    define('NOT_ACCESSIBLE', '-1');
    define('NORMAL', '0');
    define('GROUP1', '1');
    define('GROUP2', '2');
    define('GROUP3', '3');
    define('CASHIER', '4');
    define('INVENTORY_MANAGER', '5');
    define('ADMIN', '99');
    define('INVENTORY', '0x1');
    define('SALES', '0x2');
    define('REPORT', '0x3');
    define('ORDERING', '0x4');
    class Config
    {
        public static $hostname = 'localhost'; // Your MySQL hostname. Usualy named as 'localhost', so you're NOT necessary to change this even this script has already online on the internet.
        public static $dbname = 'database_'; // Your database name.
        public static $username = 'root'; // Your database username.
        public static $password = 'theboss'; // Your database password. If your database has no password, leave it empty.
        public static $url = 'http://localhost/lvt-web-pos/trunk/'; // Base url of the control panel
        public static $cpName = 'LVT WEB POS'; // Name of the control panel.
        public static $timeZone = 'Asia/Manila';
        public static $session_name = 'lvt';
        public static function getAccess()
        {
            return new Access();
        }
        public static function getKey(array $a, $pos)
        {
            $temp = array_slice($a, $pos, 1, true);
            return key($temp);
        }
		public static function setSettings()
		{
			Connection::getConnect();
			Connection::setQuery("SELECT * FROM settings");
			$set = Connection::fetch();
		    Config::$url = $set['base_url'];
        	Config::$cpName = $set['name'];
        	Config::$timeZone = $set['time_zone'];
		}
    }
    class Access
    {
        protected $pages = array(
                'main' => NON_MEMBER,
                'login' => NON_MEMBER,
                'change' => MEMBER,
                'photo' => MEMBER,
                'notification' => MEMBER,
				'pos' => MEMBER,
        );
        protected $pages2 = array(
                'reports' => 1,
                'sales' => 3,
                'inventory' => 5 ,
        );
        public function getAccess($page = 0)
        {
			if (!isset($this->pages2[$page]))
				return NON_MEMBER;
            return $this->pages2[$page];
        }
        public function getPage($page = 0)
        {
			if (!isset($this->pages[$page]))
				return NON_MEMBER;
            return $this->pages[$page];
        }
        public function getTPage($page = 0)
        {
			if (!isset($this->pages[$page]))
				return NON_MEMBER;
            return $this->tpages[$page];
        }
        public function getDPage($page = null, $node = null)
        {
            if (!is_null($node))
                return $this->dpages[$page][$node];
            return $this->dpages[$page];
        }
    }
?>